package com.huawei.fakedouyin.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池
 */
public class ThreadPool {
    private static ThreadPool threadPool;
    private ExecutorService executorService;

    public static ThreadPool getInstance() {
        synchronized (ThreadPool.class){
            if (threadPool==null){
                threadPool = new ThreadPool();
                threadPool.executorService = Executors.newCachedThreadPool();
            }
        }
        return threadPool;
    }

    public void run(Runnable runnable){
        threadPool.executorService.execute(runnable);
    }
}
